<?php
$page_title="Manage Internal Programs & Events - List";
include("includes/header.php");

$prg_id=$_GET["prg_id"];
$mode=$_GET["mode"];

if($mode=="editrem") exec_qry("update bkitc_programs set prg_brochure='' where prg_id=".$prg_id);
if($mode=="edit" || $mode=="editrem" ) 	$prg_info=@array_pop(qry_data("select * from bkitc_programs where prg_id=".$prg_id));
if($mode=="del"){
	exec_qry("update bkitc_programs set rec_status=0 where prg_id=".$prg_id);//Soft Delete
	header("location:prg_list.php");
}



?>				

<div class="fleft">
<ul class="subMenu">
<li><a href="edit_prg.php?mode=add">Add New </a></li>
<li><a href="prg_list.php?mode=result">Back to Program List </a></li>
<li><a href="edit_event_inv.php?mode=edit&prg_id=<?=$prg_id?>">Program Members </a></li>
</ul>
</div>
<div class="cleardiv"></div>
	<div style="width:100%" class="content_bg">
	<?if($mode=="edit") { ?>
	<input type="button" value="Postpone this Event" class="button" /> 	
	<input type="button" value="Cancel this Event" class="button" />	
	<? } ?>
	<form method="post" action="edit_prg_pro.php?prg_id=<?=$_GET["prg_id"]?>" enctype="multipart/form-data" > 
		<table " width="600"  cellpadding="8" border="0" cellspacing="3"> 
			<tr>
				<td  height="10" style="padding:2px;margin:2px" colspan="2" align="right"><small style="font-size:11px"> <i><?=ast()?>  Required fields.</i></small></td>
			</tr>
			<tr >
				<td width="250" class="frmLabel">Program Title <?=ast()?></td>
				<td > <input type="text" class="txtbox"  name="prg_title" size="80" value="<?=$prg_info["prg_title"]?>"> </td>
			</tr>
			<tr >
				<td width="250" class="frmLabel">Type <?=ast()?></td>
				<td > 

				<?=createSelect("prg_type", $prg_type,  $selected = $prg_info["prg_type"])?>
				
				</td>
			</tr>
			<tr >
				<td width="250" class="frmLabel">Group Type <?=ast()?></td>
				<td >
				<?=createSelect("group_loc", $group_loc,  $selected = $prg_info["group_loc"])?>
								
			
				</td>
			</tr>
			
			
			
			<tr>
				<td colspan="2">
			<div id="dvEventSection"  >
			<table width="100%" >
			<tr>
				<td width="260" class="frmLabel">Program From Date <?=ast()?></td>
				<td > 
				
					<script language="javascript">
					<?
						if($prg_info["prg_date"]=="") 
							echo "DateInput('prg_date', true, 'YYYY-MM-DD')";
						else
							echo "DateInput('prg_date', true, 'YYYY-MM-DD','".$prg_info['prg_date']."')";
					?>
					
					
					</script>
					Time : <input type="text" name="prg_f_time" class="txtbox" value="<?=$prg_info["prg_f_time"]?>">
				</td>
			</tr>
		<tr>
				<td width="260" class="frmLabel">Program To Date <?=ast()?></td>
				<td > 
				
					<script language="javascript">
					<?
						if($prg_info["prg_last_date"]=="") 
							echo "DateInput('prg_last_date', true, 'YYYY-MM-DD')";
						else
							echo "DateInput('prg_last_date', true, 'YYYY-MM-DD','".$prg_info['prg_last_date']."')";
					?>
					</script>
					Time : <input type="text" name="prg_t_time" class="txtbox" value="<?=$prg_info["prg_t_time"]?>">
				
				</td>
			</tr>
		
			<tr >
				<td  class="frmLabel"> Location  <?=ast()?></td>
				<td> <input type="text" class="txtbox"  name="prg_location" size="60" value="<?=$prg_info["prg_location"]?>"> </td>
			</tr>
			<tr >
				<td  class="frmLabel" valign="top">  Address <?=ast()?></td>
				<td > <textarea class="txtarea"   rows="5" cols="70"  name="prg_address" ><?=$prg_info["prg_address"]?></textarea> </td></td>
			</tr>
			<tr style="display:none">
				<td  class="frmLabel">Notification Email  <?=ast()?></td>
				<td > <input type="text" class="txtbox"  name="	prg_contact_email" size="60" value="<?=$prg_info["prg_contact_email"]?>"><span class="note"><br/>Admin notification email id(s) separated by ","</span> </td>
			</tr>
			</table>
			</div>
			</td>
			</tr>
			
			<tr >
				<td  class="frmLabel"> Upload Brochure  <?=ast()?></td>
				<td> <input type="file" class="txtbox"  name="prg_brochure" size="60" value="<?=$prg_info["prg_brochure"]?>"> 
				
				<?
				if($prg_info["prg_brochure"]!=""){
				
				$linkBrochure=" <a target='_blank' href='../data/prg_brochures/".$prg_id."/".$prg_info["prg_brochure"]."'>".$prg_info["prg_brochure"]."</a>";
				$linkBrochure .=" | <a href='?mode=editrem&prg_id=".$prg_id."'>Remove</a>";
				}
				
				?>
				<?=$linkBrochure?>
				</td>
			</tr>
			
			<?$arr_files=getPrgAttachmentInfo($prg_info["prg_attachments"]);
			
			
			 ?>
			<tr >
				<td  class="frmLabel" valign="top"> Upload Other Files  <?=ast()?></td>
				<td> 
				<table>
`				<?for($fctr=0;$fctr<7;$fctr++){?>
				<tr>
				<td><?=$fctr+1?>.<input type="text" class="txtbox"  name="title<?=$fctr+1?>"  placeholder="enter file <?=$fctr+1?> title" value="<?=$arr_files[$fctr]["title"]?>"/></td>
				<td> <input type="file" class="txtbox" name="file<?=$fctr+1?>" />&nbsp;<?=getLink($arr_files[$fctr]["filename"],$fctr)?></td>
				</tr>
				<? } ?>
				
				</table>
				
				
				</td>
			</tr>
			<tr >
				<td width="250" class="frmLabel">On the Spot Registrations allowed? </td>
				<td > <input type="radio"  <?=$prg_info["prg_spot_reg"]==1?"checked":""?>  name="prg_spot_reg"  id="prg_spot_reg" value="1"/> <label for="prg_spot_reg">Yes</label> <input id="prg_spot_reg1" <?=$prg_info["prg_spot_reg"]==0?"checked":""?> type="radio" name="prg_spot_reg" value="0"/> <label for="prg_spot_reg1">No</label></td>
			</tr>
			
			<tr >
				<td width="250" class="frmLabel">Event Registration Status<div>[ People cannot register for closed events ]</div> </td>
				<td > <input type="radio" name="prg_reg_open"  id="prg_reg_open" value="1"  <?=$prg_info["prg_reg_open"]==1?"checked":""?>/> <label for="prg_reg_open">Open</label> <input id="prg_reg_open1" type="radio" name="prg_reg_open" value="2" <?=$prg_info["prg_reg_open"]==2?"checked":""?>/> <label for="prg_reg_open1">Closed</label> </td>
			</tr>
			
			
			
			<tr >
				<td width="250" class="frmLabel" valign="top">Any Special Announcements/Remarks for the Event<div></div> </td>
				<td > <textarea class="txtarea"   rows="5" cols="70"  name="prg_remarks" ><?=$prg_info["prg_remarks"]?></textarea> </td></td>
			</tr>
			
			<tr>
				<td class="frmLabel" valign="top" colspan="2">Program Description / Content <?=ast()?><br/><br/>
				 <textarea class="txtarea"  id="prg_content" rows="14" cols="90" name="prg_content" style="width:800px;height:300px;"><?=$prg_info["prg_content"]?></textarea> </td>
			</tr>
			<tr style="display:none">
			<td class="frmLabel" >Enable Members to Apply</td>
			<td>
				<input type="radio"   name="rec_status" value="1" id="rdShow" <?if($prg_info["rec_status"]==1) echo "checked"; ?>> <label for="rdShow">Yes</label>
				<input type="radio"   name="rec_status"  value="2" id="rdHide" <?if($prg_info["rec_status"]==2) echo "checked"; ?>><label for="rdHide">No</label> 
			</td>
			</tr>
			
	
			<tr bgcolor="#fff" style="height:50px;margin:0px;padding:0px;">
				
				<td  style="margin:0px;padding:2px;" align="right" colspan="2">
				<input type="submit" class="button"  value="Save Info">&nbsp;
				<input class="button" type="reset">
				<input onclick="location.href='prg_list.php'"  type="button" class="button" value=" Back to Programs List">
				</td>
			</tr>
			
		</table>
	</form>
</div>

<div style="margin-bottom:40px">

</div>
<link rel="stylesheet" href="includes/wysiwyg.css" type="text/css">
<script type="text/javascript" src="includes/scripts/wysiwyg.js"></script>
<script type="text/javascript" src="includes/scripts/wysiwyg-settings.js"></script>
		<!-- 
			Attach the editor on the textareas
		-->
		<script type="text/javascript">
			
			// Use it to attach the editor directly to a defined textarea
			WYSIWYG.attach('prg_content'); // default setup
			
		</script>

<?

function getLink($fileName,$ctr){

if($fileName!=""){
$prg_id=$_GET["prg_id"];
$path="../data/prg_brochures/".$prg_id."/others/".$fileName;
return "<a href='".$path."' target='_blank'>$fileName</a> | <input type='checkbox' name=chkFileRemove".$ctr." value=1> Remove?";

}

}
?>
<? include("includes/footer.php");?>
